#—*—coding:utf-8 -*-
#@Time        :2022/7/15 21:31
#@Author      :dhx
#@File        :finance_page.py
# @Software: PyCharm
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from time import  sleep

from pages.base_pageage import BasePage
class FinancePage(BasePage):
    url="http://192.168.1.120/crm/index.php?m=business"

    finance_locator = (By.XPATH, '/html/body/div[1]/div/div/div[2]/ul[1]/li[8]/a')  # 定位财务
    add_locator = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/div[3]/a[1]')  # 添加应收款
    pay_locator = (By.XPATH, '/html/body/div[5]/div[1]/ul/li[2]/a')  # 创建应付款
    add_price_locator = (By.XPATH, '/html/body/div[5]/div[1]/ul/li[3]/a')  # 定位收款单
    payed_locator = (By.XPATH, '/html/body/div[5]/div[1]/ul/li[4]/a')  # 付款单
    create_locator = (By.XPATH, '/html/body/div[5]/p/a[5]')  # 查找下属创建
    part_locator = (By.XPATH, '/html/body/div[5]/p/a[7]')  # 部分已收
    delete_locator = (By.ID, 'delete')  # 删除
    word_locator=(By.ID,'field')#定位字段
    content_locator=(By.ID,'search')#输入内容搜索
    search_locator=(By.XPATH,'//*[@id="searchForm"]/ul/li[4]/button')#搜索框
    see_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[1]/td[11]/a[1]')  # 查看
    modif_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr/td[11]/a[2]')  # 修改

    def fince(self):
        """点击财务"""
        self.driver.find_element(*self.finance_locator).click()
    def add_price(self):
        """添加应收款"""
        self.driver.find_element(*self.add_locator).click()
        sleep(1)
    def could_pay(self):
        """点击应付款"""
        self.driver.find_element(*self.pay_locator).click()
    def will_pay(self):
        """点击收款单"""
        self.driver.find_element(*self.add_price_locator).click()

    def pay_list(self):
        """点击付款单"""
        self.driver.find_element(*self.payed_locator).click()


    def low_create(self):
        """查找下属创建"""
        self.driver.find_element(*self.create_locator).click()
    def part_collect(self):
        """点击部分已收"""
        self.driver.find_element(*self.part_locator).click()
    def delete(self):
        """点击删除"""
        self.driver.find_element(*self.delete_locator).click()
        sleep(1)
        self.driver.switch_to.alert.dismiss()
        sleep(1)

    def word_pay(self):
        """"选择字段应收款名"""
        self.driver.find_element(*self.part_locator).click()
        field = self.driver.find_element(*self.word_locator)
        select = Select(field)
        select.select_by_index(1)
    def input_content(self):
        """"输入内容"""
        self.driver.find_element(*self.content_locator).send_keys("张")

    def search_content(self):
        """"点击搜索"""
        self.driver.find_element(*self.search_locator).click()

    def see_content(self):
        """"点击查看"""
        self.driver.find_element(*self.see_locator).click()
    def modify(self):
        """开始修改"""
        self.driver.find_element(*self.modif_locator).click()













